$(window).ready(function() {
	//	登陆

	$('#name').blur(function() {
		name = $(this).val();
		if(name == '') {
			$('.warn-one').removeClass('hide');
			$('.warn-three').addClass('hide');
		} else {
			$('.warn-one').addClass('hide');
		}
	});
	$('#password').blur(function() {
		password = $(this).val();
		if(password == '') {
			$('.warn-two').removeClass('hide');
			$('.warn-three').addClass('hide');
		} else {
			$('.warn-two').addClass('hide');
		}
	});
//	登陆验证
	$('.btn').click(function() {
		var name = $('#name').val();
		var password = $.md5($('#password').val());
		$('.warn-three').addClass('hide');
		if(name != '' && password != '') {
			$.ajax({
				type: "POST",
				url: "/login/login",
				data: "name=" + name + "&password=" + password,
				dataType: "JSON",
				success: function(data) {
					if(data.code == -1){
						console.log(data);
						$('.warn-three').removeClass('hide');
					}
					if(data.code == 0){
						console.log(data);
						$('.warn-three').addClass('hide');
						window.location.href = 'index.html';
					}

				},
				error: function(data) {
					    console.log(data);
				}
			});
		}
	});

});